package ru.usu.gv.gui.routing;

import ru.usu.gv.uicomponents.UIGraph;
import ru.usu.gv.uicomponents.UIVertex;
import ru.usu.gv.utils.geometry.Polygon;

import java.awt.Color;
import java.util.ArrayList;
import java.util.List;

/**
 * @author spupyrev
 * 28.10.2009
 */
public class ObstacleCalculator
{
	private UIGraph uiGraph;

	public ObstacleCalculator(UIGraph uiGraph)
	{
		this.uiGraph = uiGraph;
	}

	public List<Polygon> calculate()
	{
		List<Polygon> result = new ArrayList<Polygon>();
		for (UIVertex v : uiGraph.getVertexes())
		{
			result.add(new Polygon(v.getViewItem().getBoundingPolygon()));
		}

		//debugShow(result);

		return result;
	}

	private void debugShow(List<Polygon> obstacles)
	{
		for (Polygon obstacle : obstacles)
			if (obstacle != null)
			{
				DebugUtilities.showPolyline(Color.ORANGE, obstacle.toControlPoints());
			}
	}
}
